﻿/*----------------------------------------------------------------
// Copyright (C) 2011 上海
// 版权所有。 
//
// 文件名：InstockDetailedInfo
// 文件功能描述：食材明细实体
//
// 
// 创建标识：2012-01-14 zhou
//
// 修改标识：
// 修改描述：
//
//
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DAO.WaiGaoQiao;

namespace Model.WaiGaoQiao
{
    public class InstockDetailedInfo : IngredientsDetailedAbstract
    {
        public InstockDetailedInfo()
        { }
        public InstockDetailedInfo(bool isgetcount)
        {
            DAID = new DataAccessInstockDetailed();
            if (isgetcount)
            {
                rowcount = GetCountInstockDetailed(string.Empty);
            }
        }
        /// <summary>
        /// 保存食材明细
        /// </summary>
        /// <param name="idab"></param>
        /// <returns></returns>
        public override int SaveInstockDetailed(IngredientsDetailedAbstract idab)
        {
            object[] idpara = new object[] {
                idab.ID,idab.InstockDt,idab.Warehouse_ID,idab.Group_ID, idab.Goods_ID,idab.Count, 
                idab.Price,idab.Amount,idab.Supplier_ID,DateTime.Now,idab.OperatorID,idab.OrderNo};
            return DAID.SaveInstockDetailed(idpara);
        }

        /// <summary>
        /// 返回食材明细数量
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public override int GetCountInstockDetailed(string condition)
        {
            return DAID.GetCountInstockDetailed(condition);
        }
        /// <summary>
        /// 删除食材明细数量
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public override int DeleteInstockDetailed(string condition)
        {
            return DAID.DeleteInstockDetailed(condition);
        }

        public int DeleteInstockDetailedWC(string condition, int id)
        {
            return DAID.DeleteInstockDetailedWC(condition, id);
        }
        /// <summary>
        /// 获取食材明细不分页
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public override IList<IngredientsDetailedAbstract> GetAllInstockDetailed(string condition)
        {
            IList<IngredientsDetailedAbstract> Idalist = new List<IngredientsDetailedAbstract>();
            DataSet ds = DAID.GetAllInstockDetailed(condition);
            InstockDetailedInfo ideinfo;
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                ideinfo = new InstockDetailedInfo()
                {
                    ID = Convert.ToInt32(item[0]),
                    InstockDt = Convert.ToDateTime(item[1]),
                    Warehouse_ID = Convert.ToInt32(item[2]),
                    Group_ID = Convert.ToInt32(item[3]),
                    Goods_ID = Convert.ToInt32(item[4]),
                    Count = Convert.ToDecimal(item[5]),
                    Price = Convert.ToDecimal(item[6]),
                    Amount = Convert.ToDecimal(item[7]),
                    Supplier_ID = Convert.ToInt32(item[8]),
                    RecordDateTime = Convert.ToDateTime(item[9]),
                    OperatorID = item[10].ToString(),
                    OrderNo = item[11].ToString()
                };
                Idalist.Add(ideinfo);
            }
            return Idalist;
        }
        /// <summary>
        /// 获取食材明细分页
        /// </summary>
        /// <param name="condition"></param>
        /// <param name="pagesize"></param>
        /// <param name="startindex"></param>
        /// <returns></returns>
        public override IList<IngredientsDetailedAbstract> GetAllInstockDetailed(string condition, int pagesize, int startindex)
        {
            IList<IngredientsDetailedAbstract> Idalist = new List<IngredientsDetailedAbstract>();
            DataSet ds = DAID.GetAllInstockDetailed(condition, pagesize, startindex);
            InstockDetailedInfo ideinfo;
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                ideinfo = new InstockDetailedInfo()
                {
                    ID = Convert.ToInt32(item[0]),
                    InstockDt = Convert.ToDateTime(item[1]),
                    Warehouse_ID = Convert.ToInt32(item[2]),
                    Group_ID = Convert.ToInt32(item[3]),
                    Goods_ID = Convert.ToInt32(item[4]),
                    Count = Convert.ToDecimal(item[5]),
                    Price = Convert.ToDecimal(item[6]),
                    Amount = Convert.ToDecimal(item[7]),
                    Supplier_ID = Convert.ToInt32(item[8]),
                    RecordDateTime = Convert.ToDateTime(item[9]),
                    OperatorID = item[10].ToString(),
                    OrderNo = item[11].ToString()
                };
                Idalist.Add(ideinfo);
            }
            return Idalist;
        }
    }
}
